from load import*
from game import*
import math

clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

from System.Drawing import *

from System.Windows.Forms import *
class Config:
    pass

z = Config()
z.drawFont = Font("Arial",12)
z.brush = SolidBrush(Color.Black)
d = 0

#ColorList

z.colorList = [Color.Blue,Color.Red,Color.Orange,Color.Purple,Color.Azure,Color.Pink,Color.Cyan,Color.Crimson,Color.BlanchedAlmond,Color.Bisque,Color.DodgerBlue]
def getTerritory(obj,e):
   click = Point(e.X,e.Y)
   print click
   
#   for t in coordinates:
#    currentDistance = 500
#    coord = Point(t[0],t[1])
#    distance(click,coord)
#    if distance < currentDistance:
#        current = t
#   print current
#   return current
#def distance(p,q):
#    d = math.sqrt((p.X - q.X)^2 + (p.Y - q.Y)^2)
#    print d
#    return d

def displayAll(obj,e):
    board = game.getBoard()
    g = e.Graphics
    for p in players:
       ts = plyrTers(game,p)
       z.brush = SolidBrush(z.colorList[p.n])
       print z.colorList[p.n]
       for t in ts:
            (x,y) = coordinates[t]
            (p,n) = game.board[t]
            s = n.ToString()
            g.DrawString(s,z.drawFont,z.brush,Point(x,y))

class MyForm(Form):
    def __init__(self):
            self.Width = 1000
            self.Height = 1000
            
            pb = PictureBox()
            pb.Width = 886 
            pb.Height = 600
            pb.BackgroundImage = Image.FromFile('riskmap2.jpg')
            self.Controls.Add(pb)
            pb.Location = Point(0,0)
            pb.Paint += displayAll
            pb.MouseClick += getTerritory
            pb.Invalidate()

form = MyForm()
Application.Run(form)

